[codex] refactor server cloud Effect services#3183
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
🚀 Expo continuous deployment is ready!
|
ApprovabilityVerdict: Approved Mechanical refactor restructuring Effect service error classes and import patterns. Error messages, handling logic, and runtime behavior remain unchanged. You can customize Macroscope's approvability policy. Learn more. |
f13cb39 to
fa1e928
Compare
Dismissing prior approval to re-evaluate fa1e928
fa1e928 to
7e190c0
Compare
Dismissing prior approval to re-evaluate 7e190c0
7e190c0 to
9b12996
Compare
Dismissing prior approval to re-evaluate 9b12996
Co-authored-by: codex <codex@users.noreply.github.com>
9b12996 to
5b7c67c
Compare
Dismissing prior approval to re-evaluate 5b7c67c
Summary
Context.Servicetagsmakeandlayervalues and reference contracts throughService["Service"]Schema.TaggedErrorClassfailures and an exportedSchema.UnionDesign notes
Credential removal, credential refresh, credential read, authorization, and authorization timeout are materially different failures, so each now has its own tag and required structured cause. The HTTP boundary handles all concrete tags through the shared inferred error union.
Both service constructors are effectful and dependency-backed, and the managed endpoint runtime owns lifecycle finalization. Their layers therefore use
Layer.effect. Existing managed-endpoint tests construct the service through its production layer so startup and finalization remain covered; no refactor-only test cases were added.Validation
vp test run apps/server/src/cloud/ManagedEndpointRuntime.test.ts apps/server/src/cloud/http.test.ts apps/server/src/server.test.ts(3 files, 110 tests)vp check(zero errors; 20 pre-existing warnings)vp run typecheckgit diff --check origin/main...HEADmake/layerpairs, zero standalone target service-shape references, exact parity across 13 changed-file test declarations, comments preserved, and no excluded pathsNote
Low Risk
Structural refactor in non-orchestration cloud paths; CLI errors gain distinct
_tagvalues but HTTP still maps them to the same internal error messages.Overview
This PR restructures the server cloud module’s Effect services without changing OAuth, tunnel, or HTTP behavior.
CLI token manager replaces one
Data.TaggedErrorwith operation-specificSchema.TaggedErrorClasstypes (read, refresh, authorize, timeout, removal) united asCloudCliTokenManagerError, and maps failures through typed constructors instead of generic message strings. The service contract moves inline onContext.Service, andmakeis exported as the canonical factory.Managed endpoint runtime drops standalone
*Shapeinterfaces, renamesmakeCloudManagedEndpointRuntimetomake(startup config + teardown finalizer live in that effect), and exposeslayerasLayer.effect(Service, make). Process/HTTP imports use explicit submodule paths.Cloud HTTP and tests switch to namespace imports and
Service["Service"]for dependency typing;reconcileDesiredCloudLinkcatches each CLI error tag separately while still surfacing the same user-facing messages viaerror.message.Reviewed by Cursor Bugbot for commit 5b7c67c. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Refactor cloud Effect services to use specific error classes and namespace imports
CloudCliTokenManagerErrorwith five specific error classes (CloudCliCredentialRemovalError,CloudCliCredentialRefreshError,CloudCliCredentialReadError,CloudCliAuthorizationError,CloudCliAuthorizationTimeoutError), each preserving the original cause.ManagedEndpointRuntimeto consolidate the factory intoexport const make, inline the service shape, and simplify layer construction.http.tsto catch and map each specific token manager error variant via a newfailCloudCliTokenManagerErrorhelper, rather than a single generic catch.Macroscope summarized 5b7c67c.